package com.ruoyi.dataserver.controller;

import cn.hutool.core.util.StrUtil;
import com.ruoyi.dataserver.utils.R;
import com.ruoyi.dataserver.service.ILTXAnalyzeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ProjectName intelligent-city
 * @Package com.lab.dataserver.controller
 * @ClassName TopologyAnalyzeController
 * @Description 连通性分析控制器
 * @Company LAB
 * @Author wangw
 * @Date 2020/7/09 11:37
 * @UpdateUser
 * @UpdateDate
 * @UpdateRemark
 * @Version 1.0.0
 */
@RestController
@RequestMapping("/ltxController")
@Slf4j
public class LTXAnalyzeController {

    @Autowired
    private ILTXAnalyzeService iltxAnalyzeService;

//    @Autowired
//    private ITestLxAnalyzeAnalyzeService testLxAnalyzeAnalyzeService;

    /**
     * @Title 联通性分析
     * @Description
     * @Param strNodeId1 : 输入为管点NodeID，和管线的SNODID或ENDOID一致
     * @Param strGXLyrID : 管线图层ID
     * @return
     * @author wangw
     * @date 2020/7/10 0010 11:35
     */
    @RequestMapping(value = "/analyze",method = RequestMethod.POST)
    public R connectednessAnalyze(@RequestBody Map map){
        if(StrUtil.isBlank(map.get("usId1").toString()) && StrUtil.isBlank(map.get("usId2").toString()) && StrUtil.isBlank(map.get("dm").toString())){
            return R.failed("参数为null.");
        }
        Map resultMap = iltxAnalyzeService.analyze(map);
        if(resultMap == null){
            return R.ok(null,"两条管线不连通.");
        }
        resultMap.put("status",true);
        /*Map map1 = (Map) resultMap.get("record");
        List list = (List) map1.get("dataList");
        R r = R.ok(list);
        return r;*/
        return R.ok(resultMap,"两条管道连通!");
    }

//    @RequestMapping(value = "/analyze1",method = RequestMethod.POST)
//    public R connectednessAnalyze1(@RequestBody Map map){
//        if(StrUtil.isBlank(map.get("usId1").toString()) && StrUtil.isBlank(map.get("usId2").toString()) && StrUtil.isBlank(map.get("dm").toString())){
//            return R.failed("参数为null.");
//        }
//        Map resultMap = testLxAnalyzeAnalyzeService.alxAnalyze(map);
//        if(resultMap == null){
//            return R.ok(null,"两条管线不联通.");
//        }
//        resultMap.put("status",true);
//        return R.ok(resultMap,"两条管道联通!");
//    }
}
